package com.gxjc.action;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;

import com.gxjc.model.User;
import com.gxjc.service.UserService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class UserAction extends ActionSupport {
	@Autowired
	UserService userService;
	public String username;
	public String password;
	public String tojsp = "";
	public String msg;
	public String login(){
		List<User> users = userService.getUserBySql("from User where username='"+username+"'");
		if(users.size()>0){
			User user = users.get(0);
			if(password.equals(user.getPassword())){
				ActionContext.getContext().getSession().put("User", user);
				tojsp = "nodedata_informationView";
				return "nowstatus";
			}else{
				tojsp = "login.jsp";
			}
		}else{
			tojsp = "login.jsp";
		}
		return SUCCESS;
	}
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getTojsp() {
		return tojsp;
	}
	public void setTojsp(String tojsp) {
		this.tojsp = tojsp;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	
}
